import { root } from "../apiRoot";
import { defHttp } from '@/utils/http';
import { IQuery, IResData } from "../types";
import { BotCardInfo, BotCompanyInfo, BotInfo, CompanyDetail, ProductInfo, TianyanchaResult, TianyanchaSearch } from "./type";
import { KnowledgeBaseFileListResult } from "../knowledgeBase/types";


const Api = {
    getByIdInfo: root + 'bot/getByIdInfo',
    botUpdate: root + 'bot/update',
    botInfoAddOrUpdate: root + 'bot/info/addOrUpdate',
    getInfo: root + 'bot/getInfo',
    getCompanyById: root + 'bot/company/getById',
    addOrUpdateCompany: root + 'bot/company/addOrUpdate',
    tianyanchaSearch: root + 'tianyancha/search',
    tianyanchaDetail: root + 'tianyancha/detail',
    deleteCompany: root + 'bot/company/del',
    addOrUpdateProductService: root + 'bot/productService/addOrUpdate',
    getProductServiceById: root + 'bot/productService/getById',
    deleteProductService: root + 'bot/productService/del',
    botAttachmentDel: root + 'bot/attachment/del',
    getBotCardById: root + 'app_bot/getBotCardById',
    getBotCompanyCardById: root + 'app_bot/getBotCompanyCardById',
    getBotProductServiceCardById: root + 'app_bot/getBotProductServiceCardById',
    selectKnowledgeBaseFileList: root + 'bot/file/attachment/getList',
    botAttachmentAddOrUpdate: root + 'bot/attachment/addOrUpdate',
}


/**
 * @description 获取智能体名片信息
 * @date 10/03/2025
 * @export
 */
export function getByIdInfo() {
    return defHttp.get<BotCardInfo>({
        url: Api.getByIdInfo,
    })
}

/**
 * @description 添加或更新智能体名片基本信息
 * @date 10/03/2025
 * @export
 */
export function botUpdate(data: BotCardInfo) {
    return defHttp.post({
        url: Api.botUpdate,
        data,
    })
}

/**
 * @description 添加或更新智能体名片联系方式
 * @date 10/03/2025
 * @export
 */
export function botInfoAddOrUpdate(data: BotInfo) {
    return defHttp.post({
        url: Api.botInfoAddOrUpdate,
        data,
    })
}

/**
 * @description 获取智能体名片联系人信息
 * @date 10/03/2025
 * @export
 */
export function getInfo() {
    return defHttp.get<BotInfo>({
        url: Api.getInfo,
    })
}

/**
 * @description 获取智能体公司信息
 * @date 10/03/2025
 * @export
 */
export function getCompanyById(id: number) {
    return defHttp.get<BotCompanyInfo>({
        url: Api.getCompanyById + '/' + id,
    })
}

/**
 * @description 添加或更新智能体公司信息
 * @date 10/03/2025
 * @export
 */
export function addOrUpdateCompany(data: BotCompanyInfo) {
    return defHttp.post({
        url: Api.addOrUpdateCompany,
        data,
    })
}

/**
 * @description 天眼查搜索
 * @date 10/03/2025
 * @export
 */
export function tianyanchaSearch(data: TianyanchaSearch) {
    return defHttp.get<IResData<TianyanchaResult>>({
        url: Api.tianyanchaSearch,
        data,
    })
}

/**
 * @description 天眼查详情
 * @date 10/03/2025
 * @export
 */
export function tianyanchaDetail(data: TianyanchaResult) {
    return defHttp.post<CompanyDetail>({
        url: Api.tianyanchaDetail,
        data,
    })
}

/**
 * @description 删除智能体公司信息
 * @date 10/03/2025
 * @export
 */
export function deleteCompany(id: number) {
    return defHttp.post({
        url: Api.deleteCompany,
        data: {
            id,
        },
    })
}

/**
 * @description 添加或更新智能体产品与服务
 * @date 10/03/2025
 * @export
 */
export function addOrUpdateProductService(data: ProductInfo) {
    return defHttp.post({
        url: Api.addOrUpdateProductService,
        data,
    })
}


/**
 * @description 获取智能体产品与服务详情
 * @date 10/03/2025
 * @export
 */
export function getProductServiceById(id: number) {
    return defHttp.get<ProductInfo>({
        url: Api.getProductServiceById + '/' + id,
    })
}

/**
 * @description 删除智能体产品与服务
 * @date 10/03/2025
 * @export
 */
export function deleteProductService(id: number) {
    return defHttp.post({
        url: Api.deleteProductService,
        data: {
            id,
        },
    })
}

/**
 * @description 删除智能体附件
 * @date 10/03/2025
 * @export
 */
export function botAttachmentDel(id: number) {
    return defHttp.post({
        url: Api.botAttachmentDel,
        data: {
            id,
        },
    })
}

/**
 * @description 获取智能体名片详情(对外)
 * @date 10/03/2025
 * @export
 */
export function getBotCardById(uuid: string) {
    return defHttp.get<BotCardInfo>({
        url: Api.getBotCardById + '/' + uuid,
    })
}

/**
 * @description 获取智能体公司名片详情(对外)
 * @date 10/03/2025
 * @export
 */
export function getBotCompanyCardById(uuid: string) {
    return defHttp.get<BotCompanyInfo>({
        url: Api.getBotCompanyCardById + '/' + uuid,
    })
}


/**
 * @description 获取智能体产品与服务名片详情(对外)
 * @date 10/03/2025
 * @export
 */
export function getBotProductServiceCardById(uuid: string) {
    return defHttp.get<ProductInfo>({
        url: Api.getBotProductServiceCardById + '/' + uuid,
    })
}


/**
 * @description 获取知识库文件列表
 * @date 06/03/2025
 * @export
 */
export function selectKnowledgeBaseFileList(data: IQuery) {
    return defHttp.post<IResData<KnowledgeBaseFileListResult>>({
      url: Api.selectKnowledgeBaseFileList,
      data,
    });
  }

  /**
 * @description 添加或更新附件
 * @date 11/03/2025
 * @export
 */
export function botAttachmentAddOrUpdate(fileKnowledgeIds: number[]) {
    return defHttp.post({
      url: Api.botAttachmentAddOrUpdate,
      data: {
        fileKnowledgeIds
      },
    });
  }